package com.itheima.edu.info.manager.service;

import com.itheima.edu.info.manager.dao.TeacherDao;
import com.itheima.edu.info.manager.domain.Teacher;

public class TeacherServicr {

    private TeacherDao dao = new TeacherDao();
    public  boolean isExists(String id) {
        Teacher [] teachers = dao.findAllTeacher();
        boolean exists =false;

        for (int i = 0; i < teachers.length; i++) {
            Teacher teacher = teachers[i];
            if (teacher != null && id.equals(teacher.getId())){
                exists = true;
            }
        }
        return exists;

    }

    public  boolean addTeacher(Teacher teacher) {

        return dao.addTeacher(teacher);
    }

    public void delTeacher(String id) {
        dao.delTeacher(id);
    }

    public void updateTeacher(Teacher tea1,String id) {
        dao.updateTeacher(tea1,id);
    }

    public Teacher[] lookTeacher() {
        Teacher [] tt =dao.findAllTeacher();
        boolean flag = false;

        for (int i = 0; i < tt.length; i++) {
            if (tt[i] != null){
                flag =true;
            }
        }
        if (false){
            return  tt;
        }else {
            //无对象时
            return null;
        }
    }
}
